q<-ggplot(data=dat, aes(x=Year,fill=Program)) +
geom_bar(stat="count")+ggtitle("Bar Plot for Year")+theme(plot.title = element_text( face="bold",size=20,hjust=0.5))
ggplotly(q)
United States included
dat<-read.csv("healthcare-spending.csv",skip=2,header=T)
dat<-dat[-(53:64),]
a<-colnames(dat)
b<-substr(a,2,5)
b[1]<-"Location"
colnames(dat)<-b
dat1<-gather(dat,Year,Health_spending,-Location)
p<-ggplot(dat1,aes(x=Year,fill=Location))+geom_bar(aes(weight = Health_spending))+ylab("Health_Spending")+theme(axis.text.x = element_text(angle=90, hjust=1))
ggplotly(p)
q<-ggplot(dat1,aes(x=Year,y=Health_spending,group=Location))+geom_line(aes(color = Location))+ylab("Health_Spending")+theme(axis.text.x = element_text(angle=90, hjust=1))
ggplotly(q)
United States excluded
date<-dat[-1,]
dat1e<-gather(date,Year,Health_spending,-Location)
p<-ggplot(dat1e,aes(x=Year,fill=Location))+geom_bar(aes(weight = Health_spending))+ylab("Health_Spending")+theme(axis.text.x = element_text(angle=90, hjust=1))
ggplotly(p)
q<-ggplot(dat1e,aes(x=Year,y=Health_spending,group=Location))+geom_line(aes(color = Location))+ylab("Health_Spending")+theme(axis.text.x = element_text(angle=90, hjust=1))
ggplotly(q)
United States included
dat2<-group_by(dat1,Location) %>%
mutate(mean=mean(Health_spending)) %>%
spread(Year,Health_spending)
p<-ggplot(dat2,aes(x=Location))+geom_bar(aes(weight =mean))+ylab("Health_Spending")+theme(axis.text.x = element_text(angle=90, hjust=1))
ggplotly(p)
United States excluded
dat2e<-group_by(dat1e,Location) %>%
mutate(mean=mean(Health_spending)) %>%
spread(Year,Health_spending)
p<-ggplot(dat2e,aes(x=Location))+geom_bar(aes(weight =mean))+ylab("Health_Spending")+theme(axis.text.x = element_text(angle=90, hjust=1))
ggplotly(p)